home *** CD-ROM | disk | FTP | other *** search
- * Program..: CHGCASE.CMD
- * Author...: Tom Rettig
- * Date.....: May 12, 1983
- * Notice...: Copyright 1983 by Ashton-Tate. All rights reserved.
- * dBASE....: II, versions 2.3x, 2.4x
- * Notes....: For changing character fields from all uppercase
- * to lowercase with the first letter capitalized.
- *
- * Substitute "Char:field" with the field name in your datafile.
- *
- * To change back to upper case, issue the command:
- * REPLACE ALL Char:field WITH !(Char:field)
- *
- ERASE
- SET TALK OFF
- SET COLON OFF
- @ 1, 0 SAY "========================================"+;
- "========================================"
- @ 2, 0 SAY "||"
- @ 2,19 SAY "C H A N G I N G T O L O W E R C A S E"
- @ 2,78 SAY "||"
- @ 3, 0 SAY "========================================"+;
- "========================================"
- *
- * Prompt user for current version of dBASE II.
- STORE "?" TO version
- DO WHILE version <> "3" .AND. version <> "4"
- @ 5,22 SAY "SELECT THE VERSION OF YOUR dBASE II:"
- @ 7,28 SAY "TYPE <3> FOR VERSION 2.3"
- @ 8,28 SAY "TYPE <4> FOR VERSION 2.4"
- @ 11,34 SAY "Version = 2." GET version
- READ
- ENDDO
- @ 5,10
- @ 7,20
- @ 8,20
- @ 11,20
- *
- * Version 2.3 does not have a RANK function like 2.4 does,
- * so create two strings in order to use a location number
- * instead of an ASCII number.
- IF version="3"
- STORE "ABCDEFGHIJKLMNOPQRSTUVWXYZ" TO ucase
- STORE "abcdefghijklmnopqrstuvwxyz" TO lcase
- ENDIF
- *
- USE Anyfile
- STORE (80-LEN(Char:field))/2 TO col
- DO WHILE .NOT. EOF
- *
- * Display the record number and uppercase field, and
- * blank the previous lowercase field if there was one.
- @ 10,col SAY Char:field
- @ 11,col-8 SAY #
- @ 12,col
- *
- * Initialize the memory variables.
- STORE " " TO new:char
- STORE F TO isreplace
- STORE 0 TO count
- *
- * Loop to work on each character one at a time
- * for the length of the field.
- DO WHILE count < LEN(TRIM(Char:field))
- STORE count+1 TO count
- STORE $(Char:field,count,1) TO char
- *
- * Determine identity of character according to version.
- IF version="3"
- *
- * Find location number in uppercase string.
- STORE @(char,ucase) to location
- *
- * If this character is in the uppercase string, and the
- * previous character was also, then replace this character
- * with the matching one from the lowercase string.
- IF location <> 0 .AND. isreplace
- STORE new:char+$(lcase,location,1) TO new:char
- ELSE
- * If this character is not in the uppercase string,
- * or if the previous character was not there,
- * do not replace.
- STORE new:char+char TO new:char
- ENDIF
- *
- ELSE
- * If this character is an uppercase letter,
- * and the previous character was also, then
- * replace with a lowercase letter.
- IF char >= "A" .AND. char <= "Z" .AND. isreplace
- STORE new:char+CHR( RANK(char)+32 ) TO new:char
- ELSE
- * If this character is not an uppercase letter,
- * or if the previous character was not alphabetical,
- * do not replace.
- STORE new:char + char TO new:char
- ENDIF
- ENDIF
- *
- * Set the logical memvar to replace the next character only if
- * this character is alphabetical (either upper or lower case).
- STORE .NOT. ( (char > "Z" .AND. char < "a");
- .OR. char < "A" .OR. char > "z" ) TO isreplace
- *
- * Display the new field as replacements are made.
- * (removing this command will speed up the operation slightly)
- @ 12,col-1 SAY new:char
- ENDDO
- REPLACE Char:field WITH $(new:char,2,LEN(TRIM(Char:field))+1)
- SKIP
- ENDDO
- @ 10,0
- @ 11,0
- @ 12,0
- @ 12,12 SAY "********** C H A N G E I S C O M P L E T E **********"
- USE Anyfile
- RELEASE ALL
- SET COLON ON
- SET TALK ON
- RETURN
- * EOF: Chgcase.cmd
-